<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

      //定义类：人类
      class People{
        //属性
       // xingming;  //姓名
       // sex;       //性别
       // age;       //年龄

        //方法：

        //特殊方法：构造器方法是在实例化类时会自动被调用
        //构造器方法通常用来初始化
        constructor(name,sexs,ages){
           // console.log(name,sexs,ages,'Hello');
           this.xingming = name;
           this.sex = sexs;
           this.age = ages;
        }


        eat(){
            console.log(`${this.xingming} ${this.sex} ${this.age} 正在吃饭...`);
        }

        work(){
            console.log(`${this.xingming} ${this.sex} ${this.age} 正在工作!`);
        }
      }

      //实例化类：创建对象
       let  lisi = new People('李四',20,'男');
       lisi.eat();
       lisi.work();

       //实例化类：创建对象
       let zhangsan = new People('张三',19,'女');
       zhangsan.work();
       zhangsan.eat();


    </script>
</head>
<body>
    
</body>
</html>